2007-03-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkentrycompletion.c (gtk_entry_completion_compute_prefix):
Ensure that the prefix is valid UTF-8. (#419568, Nickolay V. Shmyrev)
svn path=/trunk/; revision=17543
+2007-03-18 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkentrycompletion.c (gtk_entry_completion_compute_prefix):
+ Ensure that the prefix is valid UTF-8. (#419568, Nickolay V. Shmyrev)
+
2007-03-18 Matthias Clasen <mclasen@redhat.com>
* modules/input/gtkimcontextmultipress.[hc]:
else
{
gchar *p = prefix;
- const gchar *q = text;
+ gchar *q = text;
while (*p && *p == *q)
{
}
*p = '\0';
+
+ if (p > prefix)
+ {
+ /* strip a partial multibyte character */
+ q = g_utf8_find_prev_char (prefix, p);
+ switch (g_utf8_get_char_validated (q, p - q))
+ {
+ case (gunichar)-2:
+ case (gunichar)-1:
+ *q = 0;
+ default: ;
+ }
+ }
}
}